package de.hmm.hwip.connection.input;

import java.net.Socket;

import org.osgi.framework.BundleContext;

import android.util.Log;

import de.hmm.hwip.connection.api.IConIn;

/**
 *  Implementation of the network service.
 * 	Class starts a new thread when an device is connecting
 * 
 * @author johannes mendel
 * @version 27.06.2012
 * 
 */
public class InConImpl implements IConIn {
	
	/**
	 * Class identifier TAG
	 */
	private final String TAG = "InConImpl (conn. service)";

	/**OSGi Bundlecontext */
	BundleContext context;
	
	public InConImpl(BundleContext context){
		this.context = context;
	}
	
	/**
	 * starts a new thread with connection input  
	 * @param connection - socket connection input
	 * @param activity - android service activity
	 */
	@Override
	public void startCon(Socket connection, BundleContext context) {
		Log.i(TAG, "start the Connection Service: ConImpl");
		InConThread ct = new InConThread(connection, this.context);
		Thread tct = new Thread(ct);
		tct.start();
	}

	@Override
	public void getRest() {
		// TODO Auto-generated method stub
		
		System.out.println("send Rest");
		/*
		try {
			ClientResource res = new ClientResource("http://192.168.88.108:8182");
			System.out.println(res.get().getText());
		} catch (ResourceException e) {
			System.out.println("Recource exception: " + e.getMessage());
		} catch (IOException e) {
			System.out.println("IOException: " + e.getMessage());
		} 
		*/
		RestServerImpl rsi = new RestServerImpl();
		rsi.start();
	}

}
